#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# File Name   : FILENAME
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: DATETIME

"""

Usage:

"""

import os
import argparse
import logging


def get_logger(level: int = logging.INFO, log_name: str = "log01", log_file: str = "/tmp/py.log") -> logging.Logger:
    datefmt = "%Y-%m-%d %H:%M:%S"
    f_format = logging.Formatter(f"%(asctime)s - %(levelname)s - {__file__}: %(message)s", datefmt=datefmt)

    a_logger = logging.getLogger(log_name)
    a_logger.setLevel(level)

    file_handler = logging.FileHandler(log_file)
    file_handler.setFormatter(f_format)
    a_logger.addHandler(file_handler)

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(f_format)
    a_logger.addHandler(console_handler)

    return a_logger


def handle_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-c",
        dest="config",
        required=True,
        choices=["yes", "no", "only"],
        help="if perform push config operation",
        default="list",
        type=str,
    )
    parser.add_argument(
        "-i",
        "--IPs",
        dest="ip",
        nargs="*",
        default=[],
        type=str,
        help="target host ip",
    )

    return parser.parse_args()


def main():
    global log
    global IP_LIST

    os.chdir(os.path.dirname(__file__))

    log = get_logger()
    args = handle_args()


if __name__ == "__main__":
    # atexit.register()
    main()
